import { LocalstorageDataManage } from './../../common/localstoreage/localstoreageDataManage';
import { ConfigSvr } from './../services/config';
import { MessageBoxService, GrowlMessageType } from './messageBox';
import { KdsMessageType, FNCManager } from './../utils/fnc/fncManager';
import { Devices } from './../models/devices';
import { StoreSvr } from './../services/store';
import { AppStore } from './../services/appStore';
import { OrderSvr } from './../services/order';
import { ServiceBase } from './../services/base';
import { HostBinding, ChangeDetectorRef, state, style } from '@angular/core';
import { Component, ElementRef, AfterViewInit, OnDestroy, OnChanges, Input, Output, SimpleChange, EventEmitter } from '@angular/core';

@Component({
    selector: 'play-audio',
    template: `
        <div style="display:none;">
            <audio src="./assets/sounds/1.wav" id="new-order">
            您的浏览器不支持 audio 标签。
            </audio>
        </div>
    `,
})
export class PlayAudio implements IPlayAudio {
    constructor(
        private element: ElementRef
    ) {
        PlayAudioService.current.regist(this);
    }
    ngAfterViewInit() {
        this.init();
    }
    private newOrderDom;
    private remindOrderDom;
    private refundOrderDom;
    private init() {
        this.newOrderDom = this.element.nativeElement.querySelector("#new-order");
    }
    playAudio() {
        this.newOrderDom.play();
    }
}


export class PlayAudioService {
    public static current = new PlayAudioService();
    private component: IPlayAudio;
    regist(component) {
        this.component = component;
    }

    playAudio() {
        this.component.playAudio();
    }
}

interface IPlayAudio {
    playAudio();
}

